package com.xiaoxiong.adapter;

import java.util.List;

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.xiaoxiong.bean.AttendanceData;
import com.xiaoxiong.text.R;

public class AttendanceInfoAdapter extends BaseAdapter {

	private List<AttendanceData> attendancedatas;
	private Context context;
	private LinearLayout layout;

	public AttendanceInfoAdapter(List<AttendanceData> attendancedatas, Context context) {
		this.attendancedatas = attendancedatas;
		this.context = context;
	}

	@Override
	public int getCount() {
		return attendancedatas.size();
	}

	@Override
	public AttendanceData getItem(int position) {
		return attendancedatas.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@SuppressLint("ViewHolder")
	@Override
	public View getView(int position, View converView, ViewGroup parent) {
		LayoutInflater inflater = LayoutInflater.from(context);
		layout = (LinearLayout) inflater.inflate(R.layout.item_attendanceinfo, null);

		TextView code = (TextView) layout.findViewById(R.id.coursecode);
		TextView name = (TextView) layout.findViewById(R.id.coursename);
		TextView info = (TextView) layout.findViewById(R.id.attendinfo);

		code.setText(attendancedatas.get(position).getcode());
		name.setText(attendancedatas.get(position).getname());
		info.setText(attendancedatas.get(position).getInfo());
		
		return layout;
	}

}
